package com.qd.common.panda.domain.entity.func;

import com.cdqidi.util.page.BaseQuery;
import com.cdqidi.valid.group.DefaultGroup;
import com.cdqidi.valid.group.DeleteGroup;
import com.cdqidi.valid.group.UpdateGroup;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.Optional;

/**
 * 功能
 *
 * @author sjk
 */
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class ChannelFunDTO extends BaseQuery {

    /**
     * 主键
     */
    @NotBlank(message = "功能ID不能为空", groups = {DeleteGroup.class, UpdateGroup.class})
    @Size(max = 50, message = "功能ID长度不能超过{max}位", groups = {DeleteGroup.class, UpdateGroup.class})
    private String funcId;
    /**
     * 二维码地址
     */
    @Size(max = 200, message = "二维码地址长度不能超过{max}位", groups = DefaultGroup.class)
    private String qrCode;
    /**
     * 二维码地址显示
     */
    private String qrCodeDisplay;
    /**
     * 添加时间
     */
    private LocalDateTime addTime;
    /**
     * 渠道编码
     */
    @NotBlank(message = "渠道编码不能为空", groups = DefaultGroup.class)
    @Size(max = 10, message = "渠道编码长度不能超过{max}位", groups = DefaultGroup.class)
    private String channelCode;
    /**
     * 渠道编码显示
     */
    private String channelCodeDisplay;
    /**
     * 小程序功能地址
     */
    @NotBlank(message = "小程序功能地址不能为空", groups = DefaultGroup.class)
    @Size(max = 50, message = "小程序功能地址长度不能超过{max}位", groups = DefaultGroup.class)
    private String funcUrl;
    /**
     * 小程序功能地址显示
     */
    private String funcUrlDisplay;
    /**
     * 是否启用
     */
    @Size(max = 50, message = "是否启用长度不能超过{max}位", groups = DefaultGroup.class)
    private String enable;
    /**
     * 是否启用显示
     */
    private String enableDisplay;
    /**
     * 渠道推广信息
     */
    private ChannelDTO channel;

    @Override
    public void freeData() {
        this.funcId = null;
        this.qrCode = null;
        this.qrCodeDisplay = null;
        this.addTime = null;
        this.channelCode = null;
        this.channelCodeDisplay = null;
        this.funcUrl = null;
        this.funcUrlDisplay = null;
        this.enable = null;
        this.enableDisplay = null;
        Optional.ofNullable(channel).ifPresent(ChannelDTO::freeData);
        super.freeData();
    }
}
